#include <iostream>
#include <functional>

using namespace std;
using namespace std:: placeholders;

int func(int lhs, int rhs)
{
	return lhs + rhs;
}

class Foo
{
public:
	int add(int lhs, int rhs)
	{
		return lhs + rhs;
	}
};

void test1()
{
	std::function<int(int, int)> f1;
	f1 = std::bind(func, _1, _2);
	cout << f1(1, 2) << endl;
	std::function<int()> f2;
	//Foo foo;
	//f2 = std::bind(&Foo::add, &foo, 2, 3);
	f2 = std::bind(func, 2, 3);
	cout << f2() << endl;
	std::function<int(int)> f3;
	f3 = std::bind(func, _1 ,2);
	cout << f3 (3) << endl;
	f3 = std::bind(func, 2, _1);
	cout << f3(5) << endl;
}

int main()
{
	test1();
	return 0;
}
